Socket
Socket
Sign inDemoInstall

lodash.truncate

Package Overview
Dependencies
0
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lodash.truncate

The lodash method `_.truncate` exported as a module.


Version published
Weekly downloads
9.1M
decreased by-0.51%
Maintainers
3
Install size
20.4 kB
Created
Weekly downloads
 

Package description

What is lodash.truncate?

The lodash.truncate package is a utility module provided by lodash, a popular JavaScript library, that allows for truncating a string if it is longer than the given maximum string length. It provides options to customize the truncation, such as setting the length, omission string, and where to split the string.

What are lodash.truncate's main functionalities?

Basic truncation

Truncates the string to a specified length. In this example, the string 'Hello world' is truncated to 'Hello...'.

_.truncate('Hello world', { length: 5 });

Custom omission

Allows customization of the omission string that indicates text has been omitted. Here, 'Hello world' is truncated to 'Hello w---'.

_.truncate('Hello world', { length: 8, omission: '---' });

Custom separator

Truncates at the nearest character that matches the separator without breaking the word. In this case, 'Hello world' is truncated to 'Hello...'.

_.truncate('Hello world', { length: 8, separator: ' ' });

Other packages similar to lodash.truncate

Readme

Source

lodash.truncate v4.4.2

The lodash method _.truncate exported as a Node.js module.

Installation

Using npm:

$ {sudo -H} npm i -g npm
$ npm i --save lodash.truncate

In Node.js:

var truncate = require('lodash.truncate');

See the documentation or package source for more details.

Keywords

FAQs

Last updated on 13 Aug 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc